import {createRouter, createWebHistory} from 'vue-router'
import {baseRoutes} from './static'
import {BASE_URL, BASE_SHORTNAME, UseSuffix} from '@/store/config'
import useNav from '@/store/nav'

//初始化
const router = createRouter({
  history:createWebHistory(UseSuffix ? '/' + BASE_SHORTNAME + '/' : BASE_URL),
  routes:baseRoutes
})

router.beforeEach(() => {
  const nav = useNav.setup().store
  nav.navLoading = true
  return true
})

router.afterEach(() => {
  const nav = useNav.setup().store
  nav.navLoading = false
})

export default router
